package tuan.score;

import org.w3c.dom.Node;

public class EqualAttrScore extends NodeScore {
	String attrName;
	Object attrValue;
	double score;

	public EqualAttrScore(String attrName, Object attrValue, double score)
			throws Exception {
		if (attrName == null || attrValue == null) {
			throw new Exception("null arguments");
		}
		this.attrName = attrName;
		this.attrValue = attrValue;
		this.score = score;
	}

	@Override
	protected double getScore(Node node) {
		double defaultScore = 0.0;
		Object value = node.getUserData(attrName);
		if (attrValue.equals(value)) {
			return score;
		} else {
			return defaultScore;
		}
	}

}
